package com.fr.base;

import com.fr.base.core.BaseCoreUtils;
import java.io.Serializable;

public class ColumnRow
  implements Serializable, Cloneable, ColumnRowRelated
{
  public final int column;
  public final int row;

  public static ColumnRow valueOf(int paramInt1, int paramInt2)
  {
    if ((paramInt1 >= 0) && (paramInt1 < 5) && (paramInt2 >= 0) && (paramInt2 < 10))
      return ColumnRowCache.cache[paramInt1][paramInt2];
    return new ColumnRow(paramInt1, paramInt2);
  }

  public static ColumnRow valueOf(String paramString)
  {
    ColumnRow localColumnRow = valueOf(-1, -1);
    if (paramString == null)
      return localColumnRow;
    paramString = paramString.trim();
    if (!(paramString.matches("^[a-zA-Z]+[1-9]\\d*$")))
      return localColumnRow;
    try
    {
      localColumnRow = valueOf(BaseCoreUtils.convertABCToInt(paramString.replaceAll("\\d", "")) - 1, Integer.parseInt(paramString.replaceAll("[a-zA-Z]", "")) - 1);
    }
    catch (NumberFormatException localNumberFormatException)
    {
    }
    return localColumnRow;
  }

  public static boolean validate(ColumnRow paramColumnRow)
  {
    return ((paramColumnRow != null) && (paramColumnRow.getColumn() >= 0) && (paramColumnRow.getRow() >= 0));
  }

  private ColumnRow(int paramInt1, int paramInt2)
  {
    this.column = paramInt1;
    this.row = paramInt2;
  }

  public int getColumn()
  {
    return this.column;
  }

  public int getRow()
  {
    return this.row;
  }

  public ColumnRow[] getRelatedColumnRows()
  {
    return new ColumnRow[] { this };
  }

  public String toString()
  {
    return BaseCoreUtils.convertIntToABC(this.column + 1) + (this.row + 1);
  }

  public int hashCode()
  {
    int i = 17;
    i = 37 * i + this.column;
    i = 37 * i + this.row;
    return i;
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof ColumnRow))
      return false;
    ColumnRow localColumnRow = (ColumnRow)paramObject;
    return ((this.row == localColumnRow.row) && (this.column == localColumnRow.column));
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return super.clone();
  }

  ColumnRow(int paramInt1, int paramInt2, 1 param1)
  {
    this(paramInt1, paramInt2);
  }

  private static class ColumnRowCache
  {
    static final ColumnRow[][] cache = new ColumnRow[5][10];

    static
    {
      for (int i = 0; i < cache.length; ++i)
      {
        int j = 0;
        int k = cache[i].length;
        while (j < k)
        {
          cache[i][j] = new ColumnRow(i, j, null);
          ++j;
        }
      }
    }
  }
}